<?php
require_once( './path.php' );

//调用初始化页面
require_once( CLASSMATE_ROOT.'/controller/display_script_init.php' );
require_once( CLASSMATE_ROOT.'/include/function/mongo_connect.function.php' );

//@todo 
if( !session::get( 'is_online' ) ){

	 $response_message = array( 'type'=>'error' , 
	 		'content'=>'非法调用' ,
	 		'url_des'=>'返回首页' ,
	 		'url'=>'/classmate/controller/index.php' );
	 		
	 session::set( 'response_message' , $response_message );
	 header( 'Location: ../response_message.php' );
	 exit();
}

//从数据库中取出用户的相关信息
$db_connect = mongo_connect();

$db_obj_user_profile = new db_obj_user_profile( $db_connect );
$db_obj_user = new db_obj_user( $db_connect );

$email = session::get( 'email' );

$db_obj_user->load( 'email' , $email );
$db_obj_user_profile->load( 'email' , $email );

$user_complaint_process = new user_complaint_process( $db_connect );

$next_page = session::get( 'next_page' );

if ( $complaints = $user_complaint_process->get_complaint( &$max_page , $next_page ) ){

	if( $next_page < $max_page ){

		session::set( 'next_page' , $next_page+1 );
		$more = true;
	}else{

		session::set( 'next_page' , 0 );
		$more = false;
	}

	$complaints = iterator_to_array( $complaints );

}
//用户信息
$user_info = array(
	'nick' => $db_obj_user->get( 'nick' ) ,
	'reg_time' => $db_obj_user_profile->get( 'reg_time' ) ,
	'head_url_small' => $db_obj_user_profile->get( 'head_url_small' )
);

$tpl->assign( 'complaints' , $complaints );
$tpl->assign( 'user_info' , $user_info );
$tpl->assign( 'more' , $more );

$tpl->display( 'complaint/display_complaint.tpl' );


